//------------------------------------------------------------------------------
// <copyright file="TavernHeroConverter.cs" company="Damian Antonowicz">
//       copyright © 2010 Damian Antonowicz
// </copyright>
// <author>Damian Antonowicz</author>
// <email>poczta@damianantonowicz.pl</email>
//------------------------------------------------------------------------------

using System;
using System.Windows.Data;
using DotBeer.Business.Entities;

namespace DotBeer.UI.WPFClient
{
    public class TavernHeroConverter : IValueConverter
    {
        #region IValueConverter Members

        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null && value is TavernHero)
                return ((TavernHero)value).Name;
            
            return null;
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null && value is string)
                return new TavernHero() { Name = value.ToString() };

            return null;
        }

        #endregion
    }
}
